/*
 * @title: vuex全局getter配置(根)
 * @author: andy.ten@tom.com & xukaixing@hotmail.com
 * @Date: 2022-03-19 22:10:21
 * @LastEditors: andy.ten@tom.com
 * @LastEditTime: 2022-04-14 22:45:29
 * @version: 1.0.3
 * @copyright: copyright (c) 2022 andyten
 *  node: you can not copy and/or use and/or modify this program free,
 *  please reserve the segment above.Please mail me if you have any question.
 */

const getters = {
  token: (state) => state.user.token,
  refresh: (state) => state.user.refreshToken,
  loginAccount: (state) => state.user.loginAccount,
  //  language: (state) => state.user.language,
  rtflag: (state) => state.user.rtflag,
  userInfo: (state) => {
    if (state.user.userInfo)
      return JSON.parse(state.user.userInfo);
    else
      return '';
  },
  navMenus: (state) => {
    const navMenus = state.user.navMenus || '[]';
    return JSON.parse(navMenus);
  },
  sidebar: (state) => state.app.sidebar,
  language: (state) => state.app.language,
  size: (state) => state.app.size,
  device: (state) => state.app.device,
  visitedViews: (state) => state.tagsView.visitedViews,
  cachedViews: (state) => state.tagsView.cachedViews,
  avatar: (state) => state.user.avatar,
  introduction: (state) => state.user.introduction,
  roles: (state) => state.user.roles,
  permsRoutes: (state) => state.perms.routes,
  mainAppRoutes: (state) => state.perms.mainAppRoutes,
  sidebarRoutes: (state) => state.perms.sidebarRoutes,
  errorLogs: (state) => state.errorLog.logs,
  isLoadDict: (state) => state.user.isLoadDict,
  dict: (state) => {
    const dict = state.user.dict || '[]';
    return JSON.parse(dict);
  },
  dictCache: (state) => state.user.dictCache

};

export default getters;
